import 'package:flutter/material.dart';

// typedef callback = Function(int index);

class MzHomeDrawer extends StatefulWidget {
  Function(int index) callback;

  MzHomeDrawer(this.callback, {Key? key}) : super(key: key);

  @override
  _MzHomeDrawerState createState() => _MzHomeDrawerState();
}

class _MzHomeDrawerState extends State<MzHomeDrawer> {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: [
          UserAccountsDrawerHeader(
            accountName: Text("test"),
            accountEmail: Text("test1@yahoo.com"),
            currentAccountPicture: CircleAvatar(
              backgroundImage: NetworkImage(
                "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1113%2F061120115231%2F200611115231-1-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1637289576&t=ad9ca6e9301fe21ce2e32383e9ede960",
              ),
            ),
          ),
          ListTile(
            title: Text("分类"),
            leading: Icon(Icons.border_all),
            onTap: () {
              doExit(0);
            },
          ),
          // ListTile(
          //   title: Text("Android"),
          //   leading: Icon(Icons.android_sharp),
          //   onTap: () {
          //     doExit(1);
          //   },
          // ),
          // ListTile(
          //   title: Text("iOS"),
          //   leading: Icon(Icons.phone_android),
          //   onTap: () {
          //     doExit(2);
          //   },
          // ),
          // ListTile(
          //   title: Text("前端"),
          //   leading: Icon(Icons.web),
          //   onTap: () {
          //     doExit(3);
          //   },
          // ),
          // ListTile(
          //   title: Text("休息视频"),
          //   leading: Icon(Icons.video_call_sharp),
          //   onTap: () {
          //     doExit(4);
          //   },
          // ),
          // ListTile(
          //   title: Text("福利"),
          //   leading: Icon(Icons.functions),
          //   onTap: () {
          //     doExit(5);
          //   },
          // ),
          // ListTile(
          //   title: Text("拓展资源"),
          //   leading: Icon(Icons.restore_outlined),
          //   onTap: () {
          //     doExit(6);
          //   },
          // ),
          // ListTile(
          //   title: Text("我的收藏"),
          //   leading: Icon(Icons.delivery_dining),
          //   onTap: () {
          //     doExit(7);
          //   },
          // ),
          Divider(),
          ListTile(
            title: Text("about"),
            leading: Icon(Icons.supervisor_account),
            onTap: () {
              doExit(8);
            },
          ),
        ],
      ),
    );
  }

  doExit(int index) {
    widget.callback.call(index);
    Navigator.of(context).pop();
  }
}
